/*
 * WRMTransactionsModule.java   ver    9 Nov 2009
 * 
 * Copyright (c) 2009 mentalsmash.org
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * The use of the Apache License does not indicate that this project is
 * affiliated with the Apache Software Foundation.
 */
package org.mentalsmash.tazio.transactions.modules;

import org.mentalsmash.tazio.transactions.control.Snapshooter;
import org.mentalsmash.tazio.transactions.control.SystemTransactionManager;
import org.mentalsmash.tazio.transactions.control.TazioTransaction;
import org.mentalsmash.tazio.transactions.control.TransactionsLog;
import org.mentalsmash.tazio.transactions.control.ValidationAgent;
import org.mentalsmash.tazio.transactions.control.impl.BackwardValidationAgent;
import org.mentalsmash.tazio.transactions.control.impl.BasicTransactionsLog;
import org.mentalsmash.tazio.transactions.control.impl.ReadOnlyTransaction;
import org.mentalsmash.tazio.transactions.control.impl.ReadWriteTransaction;
import org.mentalsmash.tazio.transactions.control.impl.SnapshooterImpl;
import org.mentalsmash.tazio.transactions.control.impl.TazioTransactionImpl;
import org.mentalsmash.tazio.transactions.control.impl.WRMTransactionManager;
import org.mentalsmash.tazio.transactions.model.RootSet;
import org.mentalsmash.tazio.transactions.model.identifiers.OID;
import org.mentalsmash.tazio.transactions.model.identifiers.TID;
import org.mentalsmash.tazio.transactions.model.impl.TazioRootSet;
import org.mentalsmash.tazio.transactions.model.impl.TxObjectWrapperFactory;
import org.mentalsmash.tazio.transactions.model.impl.TxObjectWrapperFactoryImpl;
import org.mentalsmash.tazio.transactions.rm.RMTransactionsFacade;
import org.mentalsmash.tazio.transactions.user.Share;
import org.mentalsmash.tazio.transactions.user.Transaction;
import org.mentalsmash.tazio.transactions.user.UserTransactionManager;
import org.mentalsmash.tazio.transactions.user.impl.RootSetWrapper;
import org.mentalsmash.tazio.transactions.wrm.RMTransactionsFacadeProxy;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;

/**
 * @author Andrea Reale
 * @version ver
 */
public class WRMTransactionsModule extends AbstractModule {

    /*
     * (non-Javadoc)
     * 
     * @see com.google.inject.AbstractModule#configure()
     */
    @Override
    protected void configure() {
	bind(WRMTransactionManager.class);
	bind(SystemTransactionManager.class).to(WRMTransactionManager.class);
	bind(UserTransactionManager.class).to(WRMTransactionManager.class);
	bind(TransactionsLog.class).to(BasicTransactionsLog.class);
	bind(ValidationAgent.class).to(BackwardValidationAgent.class);
	bind(Snapshooter.class).to(SnapshooterImpl.class);

	bind(RootSet.class).to(TazioRootSet.class);
	bind(Share.class).to(RootSetWrapper.class);
	
	bind(TazioTransaction.class).to(TazioTransactionImpl.class);
	bind(TazioTransactionImpl.class).to(ReadWriteTransaction.class);
	bind(TazioTransactionImpl.class).annotatedWith(ReadOnly.class).to(
		ReadOnlyTransaction.class);

	bind(TxObjectWrapperFactory.class).to(TxObjectWrapperFactoryImpl.class);
	
	bind(RMTransactionsFacade.class).to(RMTransactionsFacadeProxy.class);
	// Executors bindings

    }

    @Provides
    TID generateTID() {
	return TID.generateTID();
    }

    @Provides
    OID generateOID() {
	return OID.generateOID();
    }

}
